var express =require('express')
var path = require('path')
var bodyParser = require('body-parser')
var router = require('./routes/router')
var session = require('express-session')
var app = express()

app.use('/public/',express.static(path.join(__dirname, './public')))
app.use('/node_modules/',express.static(path.join(__dirname,'./node_modules')))

app.engine('art',require('express-art-template'))

app.set('views',path.join(__dirname,'./views'))

app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
app.use(session({
    secret: 'hmblog session',
    resave: false,
    saveUninitialized: true
}))


app.use(router)

app.use(function(err,res){
    res.status(500).json({
        code:500,
        msg:err.message,
    })
})

app.listen(3000,function(){
    console.log('HMBlog server is running at port 3000...')
})